package com.shkco.xbjcc.web.controller;

import com.shkco.result.JSONResult;
import com.shkco.xbjcc.domain.AlipayInfo;
import com.shkco.xbjcc.dto.AlipayNotifyDto;
import com.shkco.xbjcc.dto.PayParamDto;
import com.shkco.xbjcc.service.IPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/pay")
public class PayController {

    @Autowired
    private IPayService payService;

    @RequestMapping(value = "/checkPayOrder/{orderNo}",method = RequestMethod.GET)
    public JSONResult checkPayOrder(@PathVariable("orderNo")String orderNo){
        return payService.checkPayOrder(orderNo);
    }

    @RequestMapping(value="/apply",method= RequestMethod.POST)
    public JSONResult apply(@RequestBody @Valid PayParamDto payParamDto){
        return JSONResult.success(payService.apply(payParamDto));
    }

    @RequestMapping(value="/alipay/notify",method= RequestMethod.POST)
    public String alipayNotify(AlipayNotifyDto alipayNotifyDto){
        return payService.alipayNotify(alipayNotifyDto);
    }
}
